package show.me.the.money.util.exp.standard;

import java.util.List;

import show.me.the.money.util.context.Context;
import show.me.the.money.util.exp.ExpRunner;
import show.me.the.money.util.exp.ExpSymbols;
import show.me.the.money.util.exp.Expression;

@SuppressWarnings("unchecked")
public class GE extends Expression {
	public GE() {
		symbol = ExpSymbols.GE;
	}

	public String run(List lsExp, Context ctx) {
		Boolean result = true;
		try {
			List la1 = (List)lsExp.get(1);
			double d1 = (Double)(ExpRunner.run(la1, ctx));
			int size = lsExp.size();
			for (int i = 2; i < size; i++) {
				List la2 = (List)lsExp.get(i);
				double d2 = (Double)ExpRunner.run(la2, ctx);
				if (d1 < d2) {
					result = false;
					break;
				}
				d1 = d2;
			}
		} 
		catch (Exception e) {
			logger.fatal("run JSONException:", e);
		}
		return String.valueOf(result);
	}

	public String toString(List lsExp, Context ctx) {
		return super.toString(lsExp, ctx);
	}

}
